# -*- coding: utf-8 -*-
# @Time    : 2021/10/29 19:37
# @Author  : XIEHAO
# @Email   : xiehao_1989@126.com
# File     : urls.py
# @Software: PyCharm
from django.urls import path
from rest_framework.routers import SimpleRouter

from .views import StudentViewSet, ClassesViewSet

urlpatterns = [
    # path('students/', StudentViewSet.as_view({'get': 'list', 'post': 'create'})),
    # path('students/<pk>/', StudentViewSet.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy'})),
]
# 使用路由器创建路由，路由器只能用于视图集
router = SimpleRouter()  # 实例化路由器对象
router.register('students', StudentViewSet)  # 注册路由器 ，students: 路由地址
router.register('classes', ClassesViewSet)  # 注册路由器 ，classes: 路由地址
urlpatterns += router.urls  # 获取生成的路由器列表
